<template>
	<div class="style">
		<div>
			<label>{{ $t('route.Device_Configuration') }}</label>
			<div></div>
			<button><img /><label>{{ $t('route.Production_of_single') }}</label></button>
		</div>

		<div>
			<div>

				<div class="div-handle-right">
					<el-button @click="jumpPage('add-pro-order')" type="primary" plain>{{ $t('route.Add') }}</el-button>
				</div>
			</div>

			<el-table class="table" :data="proOrderList" style="width: 100%" >
				<el-table-column width="300" :label="$t('route.Style_picture') " >
					<template #default="scope">
						<img class="style-img" :src="scope.row.styleIcon">
					</template>
				</el-table-column>
				<el-table-column :label="$t('route.Order_information')">
					<template #default="scope">
						<div class="table-row-label">{{ $t('route.Payment_Number') }}：{{ scope.row.styleCode }}</div>
						<div class="table-row-label">{{ $t('route.Item_name') }}：{{ scope.row.styleName }}</div>
						<div class="table-row-label">{{ $t('route.Customer') }}：{{ scope.row.customer }}</div>
						<div class="table-row-label">{{ $t('route.total_quantity') }}：{{ formatNum(scope.row.numList) }}</div>
						<div class="table-row-label">{{ $t('route.SAM') }}：{{ scope.row.sam }}</div>
					</template>
				</el-table-column>
				<el-table-column  width="350" :label="$t('route.production_information')">
					<template #default="scope">
						<div class="table-row-label">{{ $t('route.date_of_delivery') }}：{{ scope.row.deliveryDate }}</div>
						<div class="table-row-label">{{ $t('route.Actual_delivery_date') }}：</div>
						<div class="table-row-label">{{ $t('route.Processing_production_line') }}：{{ scope.row.workshop + ' ' + scope.row.proLine }}</div>
						<div class="table-row-label">{{ $t('route.Launch_date') }}：{{ scope.row.launchDate }}</div>
						<div class="table-row-label">{{ $t('route.Target_output') }}：{{scope.row.dailyNum}}</div>
						<div class="table-row-label">{{ $t('route.Actual_production') }}：0</div>
					</template>
				</el-table-column>
				<el-table-column  :label="$t('route.see')" align="center">
					<template #default="scope">
						<el-button @click="jumpPage('pro-plan', scope.row)" type="primary" plain>{{ $t('route.Scheduling_plan') }}</el-button>
						<div class="mgr-top-10"></div>
						<el-button @click="jumpPage('device-allocated', scope.row.id)" type="primary" plain>{{ $t('route.Device_Configuration') }}</el-button>
					</template>
				</el-table-column>
				<el-table-column  :label="$t('route.operate')" align="center">
					<template #default="scope">
						<el-button @click="jumpPage('add-pro-order', scope.row)" type="text">{{ $t('route.Editing') }}</el-button>
						<div class="mgr-top-10"></div>
						<el-button @click='deleteClick(scope.row.id)' type="text"  style="color: #FF0000;" >{{ $t('route.Delete') }}</el-button>

					</template>
				</el-table-column>
			</el-table>
			<div class="pagination">
				<el-pagination style="float: right;" background @current-change="handlePageChange"
					:current-page="query.pageNum" :page-size="query.pageSize" layout="total, prev, pager, next"
					:total="query.total"></el-pagination>
			</div>
		</div>
	</div>
</template>

<script>
import http from "../../js/http/http.js";
import api from "../../js/http/api.js";
import i18n from '../../i18n/index';
export default {
	data() {
		return {
			query: {
				pageNum: 1,
				pageSize: 5,
				total: 0,
				search: null,
			},
			proOrderList: [],
		};
	},
	methods: {
		formatNum(numList) {
			var allNum = 0;
			for (var item of JSON.parse(numList)) {
				allNum += parseInt(item.num);
			}
			return allNum;
		},
		getProOrderList() {
			http.post(api.GET_PRO_ORDER_LIST, {
				pageNum: this.query.pageNum,
				pageSize: this.query.pageSize,
				adminId: this.$store.state.user.id
			}, data => {
				this.proOrderList = data.data.proOrderList;
				this.query.total = data.data.total;
			});
		},
		jumpPage(pathName, param) {
			this.$store.commit("setProOrder", null);
			this.$router.push({
				name: pathName,
				params: {
					proOrder: JSON.stringify(param),
					styleId: param,
					proOrderId: param
				}
			});
		},


		deleteClick(proOrderId) {
			this.$confirm(i18n.global.t('route.continue13'), i18n.global.t('route.reminder'), {
				confirmButtonText: i18n.global.t('route.sure'),
				cancelButtonText: i18n.global.t('route.cancel'),
				type: 'warning'
			}).then(() => {
				http.post(api.DELETE_PRO_ORDER, {
					proOrderId: proOrderId
				}, data => {
					this.$message.success(i18n.global.t('route.Delete_succeeded'));
					this.getProOrderList();
				});
			});

		},
		handlePageChange(pageNum) {
			this.query.pageNum = pageNum;
			this.getProOrderList();
		},

	},
	created() {
		this.getProOrderList();
       
	}
};
</script>
<style lang="scss" scoped>
.style {
	color: #444444;
	font-size: 18px;
	padding-right: 20px;
	height: calc(100vh - 100px);
	// overflow: scroll;
	scrollbar-width: none;
	/* firefox */
	-ms-overflow-style: none;
	/* IE 10+ */
	overflow-x: hidden;
	overflow-y: auto;

	>div {
		display: flex;
		flex-direction: row;
		margin-top: 20px;
		background-color: #ffffff;
		padding: 20px;
		border-radius: 5px;
	}

	>div:nth-of-type(1) {
		>label:nth-of-type(1) {
			font-weight: 600;
		}

		>div:nth-of-type(1) {
			width: 1px;
			background-color: #cccccc;
			height: 15px;
			margin: 0px 20px;
		}

		>button:nth-of-type(1) {
			background-image: url(../../assets/img/customer-1.png);
			background-repeat: no-repeat;
			background-size: 100% 100%;
			padding: 5px 10px;
			border: 0px;
			display: flex;
			color: #ffffff;
			flex-direction: row;
			align-items: center;
			font-weight: 800;

			>img {
				margin-right: 7px;
				width: 15px;
				height: 15px;
				content: url(../../assets/img/customer-2.png);
			}

		}
	}

	>div:nth-of-type(2) {
		flex-direction: column;

		.table {
			.table-row-label {
				margin-top: 5px;
				font-size: 15px;
			}

			.style-img {
				width: 120px;
				height: 120px;
			}
		}

		>div:nth-of-type(1) {
			display: flex;
			flex-direction: row;
			align-items: center;

			.div-handle-right {
				flex: 1;
				flex-direction: row-reverse;
				text-align: right;
				display: flex;
				align-items: center;

				>input:nth-of-type(1) {
					border: 1px solid #eeeeee;
					font-size: 15px;
					width: 150px;
					padding: 5px 8px;
					outline: none;
				}

				>button {
					color: #A866FF;
					margin-left: 10px;
					padding: 4px 20px;
				}
			}
		}

		.table {
			margin-top: 20px;
		}

	}
}
</style>
